import { legacy_createStore as createStore, combineReducers, Store, applyMiddleware } from "redux";
import storage from "redux-persist/lib/storage";
import { persistStore, persistReducer } from "redux-persist";
import {composeWithDevTools }from 'redux-devtools-extension'
import global from "./modules/global/reducer";
import menu from "./modules/menu/reducer";

// 创建reducer(拆分reducer)
const reducer = combineReducers({
	menu,
	global,
});
const persistConfig = {
	key: "redux-state",
	storage: storage
};
const persistReducerConfig = persistReducer(persistConfig, reducer);

// 创建 store
const store: Store = createStore(persistReducerConfig, composeWithDevTools(applyMiddleware()));
// 创建持久化 store
const persistor = persistStore(store);

export { store,persistor };
